package sk.fiit.lulco.grafy;

import java.util.Random;

public class RandomColoringAlgorithm extends AbstractAlgorithm {
	
	/**
	 * set random color (maximal chromatic number color) for all vertices which are not colored
	 * 
	 * @return	void
	 */
	public Graph color(Graph graph) {
		int maxColor = graph.getBestColoring() > 0 ? graph.getBestColoring() : graph.getVertices().size();
		for (Vertex vertex : graph.getVertices()) {
			if (vertex.getColor() == 0) {
				Random rand = new Random();
				vertex.setColor(rand.nextInt(maxColor) + 1);
			}
		}
		return graph;
	}
}
